package seabattle.movements;

import seabattle.io.Command;
import seabattle.ship.Coordinates;

public class WebPlayerMovement implements Movement {
	private String reader;

	public WebPlayerMovement(String reader) {
		this.reader = reader;
	}

	public Coordinates getShot() {
		Command command = new Command(reader);
		int x, y;
		try {
			y = command.getY();
			if (y < 0) {
				return null;
			}
		} catch (RuntimeException e) {
			return null;
		}
		try {
			x = command.getX();
		} catch (RuntimeException e) {
			return null;
		}
		if ((x > -1) && (y > -1)) {
			return new Coordinates(x, y);
		}
		return null;
	}

}
